//
//  YKDebugManager.swift
//  YKSwiftDebugManager
//
//  Created by edward on 2021/12/1.
//

import UIKit

public class YKDebugManager: NSObject {
    public static let share:YKDebugManager = YKDebugManager.init()
    
    public var clickDebugWindow:(()->Void)? = nil
    
    private lazy var debugWindow:DebugWindow = {
        let window = DebugWindow.init(frame: CGRect(x: 0, y: 360, width: 40, height: 40)) {
            if self.clickDebugWindow != nil {
                self.clickDebugWindow!()
            }else{
                self.dissMissMainWindow()
            }
        }
        return window
    }()
    
    private override init() {
        super.init()
    }
    
    public func install() -> Void {
        #if DEBUG
        self.debugWindow.isHidden = false
        #endif
    }
    
    
    private func dissMissMainWindow()->Void
    {
        DebugMainWindow.share.showOrDissMiss()
    }
    
    public static func addSwitchItemDetail(switchName:String, switchItemNotificationName:String, itemCallBack:@escaping ((Bool)->Bool))->Void{
        DebugManagerUtil.share.addSwitchItemDetail(switchName: switchName, switchItemNotificationName: switchItemNotificationName, itemCallBack: itemCallBack)
    }
    
    /// 添加私人工具
    /// - Parameters:
    ///   - itemImage: 工具图标
    ///   - itemTitle: 工具名称
    ///   - itemClickBlock: 工具点击回调  其中 callBack
    ///   - callBack:UIViewController  传入你想打开的页面
    ///   - callBack:Int      传入你想打开的页面的方式 0 为 push  1为 present
    ///   - callBack:Bool      传入你想打开的页面的动画方式
    ///   - dissMissMain  点击响应后是否取消Debug主界面
    /// - Returns: 无
    public static func addCustomItem(itemImage:UIImage, itemTitle:String, itemClickBlock:@escaping ((_ callBack:((UIViewController,Int,Bool)->Void),_ dissMissMain:(()->Void))->Void))->Void{
        
        DebugManagerUtil.share.addCustomItem(itemImage: itemImage, itemTitle: itemTitle, itemClickBlock: itemClickBlock)
    }
}
